layui.define(['jquery', 'layer', 'form', 'carousel'], function(e) {
    "use strict";
    var $ = layui.$,
        layer = layui.layer,
        form = layui.form,
        util = layui.util,
        carousel = layui.carousel;
    /**
    * banner图轮播
    **/
    carousel.render({
        elem: '#banner',
        width: '100%', //设置容器宽度
        height: '100%' //设置容器高度
    });
    // 图表
    /*var n = function (opts){
        return [{
            color: ['#0045ad'],
            xAxis: {
                type: "category",
                data: ["1", "2", "3", "4", "5", "6", "7"]
            },
            yAxis: {
                type: "value"
            },
            tooltip: {
                trigger: 'axis'
            },
            grid: {
                left: '0',
                right: '0',
                top:'10px',
                bottom: '0',
                containLabel: true
            },
            series: [{
                name: "PV",
                type: "line",
                data: [111, 9, 250, 9, 250, 9, 250]
            }]
        }, {
            color: ['#0045ad'],
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            grid: {
                left: '0',
                right: '0',
                top:'10px',
                bottom: '0',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    data: ['仓库1', '仓库2', '仓库3', '仓库4'],  //仓库名称
                    axisTick: {
                        alignWithLabel: true
                    }
                }
            ],
            yAxis: [
                {
                    type: 'value'
                }
            ],
            series: [
                {
                    name: '直接访问',
                    type: 'bar',
                    barWidth: '60%',
                    data: [10, 52, 200, 334]        //仓库木材
                }
            ]
        }];
    }
    var echarts1 = echarts.init(document.getElementById('echarts1'));
        echarts1.setOption(n()[0]);
    var echarts2 = echarts.init(document.getElementById('echarts2'));
        echarts2.setOption(n()[1]);
    // 仓库图片切换
    form.on('checkbox(warehouse)', function(data){
        console.log(data.elem); //得到checkbox原始DOM对象
        console.log(data.elem.checked); //是否被选中，true或者false
        console.log(data.value); //复选框value值，也可以通过data.elem.value得到
        console.log(data.othis); //得到美化后的DOM对象
    });*/
    /**
    * 推荐商家轮播
    **/
    carousel.render({
        elem: '#business-shop',
        width: '100%',  //设置容器宽度
        height: '100%', //设置容器高度
        arrow: 'none'
    });

    /**
    *买家服务卖家服务切换
    **/
    $('.screen-ot-item').on('click', function (event) {
        event.preventDefault();
        var isCur = $(this).hasClass('cur');
        if (!isCur) {
            var i = $(this).index();
            $(this).addClass('cur').siblings().removeClass('cur');
            $('.screen-oc-item').eq(i).addClass('cur').siblings().removeClass('cur');
        }
        return;
    });
    /**
    *报价中心求购大厅切换
    **/
    $('.i-mall-tag').on('click', function (event) {
        event.preventDefault();
        var isCur = $(this).hasClass('cur');
        if (!isCur) {
            var i = $(this).index();
            $(this).addClass('cur').siblings().removeClass('cur');
            $('.i-mall-bottom .i-mall-list').eq(i).addClass('cur').siblings().removeClass('cur');
        }
        return;
    });

    //仓库实景
    //  if (warehouse.length>0) {
    //      var live_action = $('.exp-warehouse .exp-content img');
    //      live_action.attr('src', IMG_URL + warehouse[0].img_path);
    //      form.on('select(live-action)', function(data) {
    //          warehouse.forEach(function(val, index) {
    //              if (data.value == val.id) {
    //                  live_action.attr('src', IMG_URL + val.img_path);
    //              }
    //          });
    //          form.render('select');
    //      });
    //  }

    e('index', null);
});
